package com.hyh.shiyanshiguanli.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.hyh.shiyanshiguanli.domain.dto.MessageDTO;
import com.hyh.shiyanshiguanli.domain.dto.PageDTO;
import com.hyh.shiyanshiguanli.domain.entity.Instrument;
import com.hyh.shiyanshiguanli.domain.entity.Reagent;
import com.hyh.shiyanshiguanli.domain.result.PageResult;
import com.hyh.shiyanshiguanli.mapper.LibAssetMapper;
import com.hyh.shiyanshiguanli.service.LibAssetService;
import com.hyh.shiyanshiguanli.service.LibService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author hyh
 * @version 1.0
 */
@SuppressWarnings({"ALL"})
@Service
public class LibAssetServiceImpl implements LibAssetService {

    @Autowired
    LibAssetMapper libAssetMapper;

    @Override
    public PageResult pageInstrument(PageDTO pageDTO) {

        PageHelper.startPage(pageDTO.getPage(),pageDTO.getPageSize());

        Page<Instrument> instruments = libAssetMapper.pageInstrument(pageDTO);

        long total = instruments.getTotal();
        List<Instrument> result = instruments.getResult();

        PageResult result1 = new PageResult();
        result1.setTotal(total);
        result1.setRecodes(result);

        return result1;

    }

    @Override
    public PageResult pageShiJi(PageDTO pageDTO) {
        PageHelper.startPage(pageDTO.getPage(),pageDTO.getPageSize());

        Page<Reagent> reagents = libAssetMapper.pageShiJi(pageDTO);

        long total = reagents.getTotal();
        List<Reagent> result = reagents.getResult();

        PageResult result1 = new PageResult();
        result1.setTotal(total);
        result1.setRecodes(result);

        return result1;
    }
}
